//
//  CPDownloadTools.h
//  Teacher App
//
//  Created by collegepre on 16/7/28.
//  Copyright © 2016年 collegepre. All rights reserved.
//

#import "DCDownload.h"
#import "DCDownloadOprationManager.h"

// 过期
#define DCExtensionDeprecated(instead) NS_DEPRECATED(2_0, 2_0, 2_0, 2_0, instead)


@class CPDownloadInfo,DCOSSDDownloadOpration;

@interface CPDownloadTools : NSObject

@property (copy,nonatomic) CPDonwloadCompliction donloadCompliction;

@property (copy,nonatomic) CPDownloadProgress progressBlock;

@property (copy,nonatomic) CPDownloadUnzipProgress unziprogress;

@property (copy,nonatomic) CPDownloadUnzipProgress decryptMediaProgress;

@property (nonatomic, assign) NSInteger  maxQueueNum;
/**
 *  老的下载方法
 *
 *  @param url             下载地地址
 *  @param destinationPath 目标目录
 *  @param unzipPath       解压目录
 *  @param header          头
 *  @param key             key
 *  @param md5             md5
 *  @param progress        进度回调
 *  @param statechange     状态更改
 *  @param complition      完成回调
 *
 *  @return 下载进程
 */
- (void)cp_downloadLessonWithURL:(NSString *)url toDestinationPath:(NSString *)destinationPath unzipPath:(NSString *)unzipPath header:(NSString *)header key:(NSString *)key zipMD5:(NSString *)md5 progress:(DCDownloadOprationResuming)progress state:(DCDownloadStateChangeBlock)statechange donwloadComplition:(CPDonwloadCompliction)complition DCExtensionDeprecated("请使用cp_downloadCoursePakageZipWithDonloadInfo 或cp_downloadCoursePakageZipWithDonloadJson 方法代替");

/**
 *  初始化方法
 *
 *  @return 实例化对象
 */
+ (instancetype)shareDownloadTools;
/**
 *  字典转下载模型信息
 *
 *  @param dict  示例字典 NSDictionary *dict = @{@"destinationPath":@"",@"downloadType":@1,@"downloadURL":@"",@"osskey":@"course/0FAB797780A84473B0770D368D18D2A5",@"unzipPath":@"",@"totalSize":@0,@"courseSecurityInfo":@{@"header":@"",@"key":@"",@"md5":@""}};
 *
 *  @return 下载模型信息
 */
- (CPDownloadInfo *)downloadInfoWithCourseJson:(NSDictionary *)dict;



/**
 *  根据下载信息<>
 *
 *  @param downloadInfo 下载信息
 *  @param progress     下载进度回调
 *  @param complition   下载完成后回调
 */
- (void)cp_downloadCoursePakageZipWithDonloadInfo:(CPDownloadInfo *)downloadInfo progress:(CPDownloadProgress)donwloadProgress donwloadComplition:(CPDonwloadCompliction)complition unzipProgress:(CPDownloadUnzipProgress)unzipProgress decryptMediaProgress:(CPDownloadUnzipProgress)decryptProgress;

/**
 *  根据传的下载信息直接下载课件包
 *
 *  @param downloadInfo     下载信息
 *  @param donwloadProgress 进度回调
 *  @param complition       完成回调
 *  @param unzipProgress    解压进度回调
 *  @param decryptProgress  解密进度回调
 */
- (void)cp_downloadCoursePakageZipWithDonloadJson:(NSDictionary *)dict progress:(CPDownloadProgress)donwloadProgress donwloadComplition:(CPDonwloadCompliction)complition unzipProgress:(CPDownloadUnzipProgress)unzipProgress decryptMediaProgress:(CPDownloadUnzipProgress)decryptProgress;

/**
 *  暂停所有下载请求
 */
- (void)spausedAllDownloadOpration;

/**
 *  暂停一个下载请求
 *
 *  @param info 下载请求信息
 */
- (void)spausedDownloadOpration:(CPDownloadInfo *)info;


/**
 *  开始所有下载请求
 */
- (void)startAllDownloadOpration;

/**
 *  开始某一个下载请求
 *
 *  @param info 下载请求信息
 *
 *  @return 是否成功<如果没有该请求返回NO>
 */
- (void)startDownloadOpration:(CPDownloadInfo *)info;


@end
